<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:c="http://www.w3.org/1999/XSL/Transform">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title></title>
    <link rel="stylesheet" href="css/jquery.mobile-1.4.5.min.css" />
    <script src="js/jquery.min.js"></script>
    <script src="js/jquery.mobile-1.4.5.min.js"></script>
    <script>
    	$("#mypanel").trigger("updatelayout");
   	</script>
   	<script>
   		$(document).ready(function() {
   			$("div").bind("swiperight",function(event) {
   				$("#mypanel").panel("open");
   			});
   		});
   	</script>
   	<script>
   		function come(){
   			window.location.href="/index02";
   		};
   	</script>
   	<script>
   		$(document).ready(function(){
   			getdz();
   			getlist();
    	});
    	//统计点赞数
    	function getdz(){
    		$.ajax({
    			type:"GET",
    			url:"http://192.168.43.203:8080/myfriend/countdzservlet",
    			async:false,
    			dataType:"json",
    			success:function(data){
					$(data).each(
	                    function(i, values) {
	                        $("#li01").append(
	                           "所得点赞数："+values
	                
	                        );
	 
	                    }
                	);
				
    			},
    		});
    		
    	}
    	//获得列表
    	function getlist(){
    		$.ajax({
    			type:"GET",
    			url:"http://192.168.43.203:8080/myfriend/selectservlet",
    			async:false,
    			dataType:"json",
    			success:function(data){
					$(data).each(
	                    function(i, values) {
	                        $("#li02").append(
	                          
		                		"<div class='ui-grid-a'>"
								+"<div class='ui-block-a'><p>"+values.pltext+"</p></div>"
								+"<div class='ui-block-b'><button onclick='getid("+values.id+")'>删除"+"</button></div>"
								+"</div>"
	                        );
	 
	                    }
                	);
				
    			}
    		});	
    	}
   	</script>
   	<script>
   		//删除
    	function getid(id){
    		$.ajax({
    			type:"post",
    			url:"http://192.168.43.203:8080/myfriend/deleteservlet",
    			data:{"id":id},
    			async:false,
    			dataType:"json",
    			success:function(data,status){
  					alert("删除成功");
//					alert(data[0].key);
					if(data[0].key==1){
						window.location.href="ht.html";
					}
    			}
    		});
    	}
   	</script>
   	<style>
   		.ui-grid-a .ui-block-a-1
   		{
   			width: 80%;
   		}
   		.ui-grid-a .ui-block-b-2
   		{
   			width: 20%;
   		}
   	</style>
</head>
<body>
	<div data-role="page" class="pagecolor">
		<div data-role="panel" id="mypanel" data-swipe-close="false">
			<h4>作者：梁海琦</h4>
			<h4>作者介绍</h4>
			<p>就读于东莞理工学院城市学院</p>
			<p>性格开朗、稳重、有活力，待人热情、真诚；工作认真负责，积极主动，
			能吃苦耐劳，用于承受压力，勇于创新；有很强的组织能力和团队协作精神，
			具有较强的适应能力；纪律性强，工作积极配合；意志坚强，具有较强的无私奉献精神</p>
		</div>
		<div data-role="header" data-position="fixed" data-theme="b">
			<a  th:href="@{/index02}" onclick="come()" data-role="button" data-iconpos="left" data-icon="arrow-l">返回</a>
			<h1>我的伙伴</h1>
			<a href="#mypanel" data-role="button" data-iconpos="right" data-icon="grid">关于</a>	
		</div>
		<div data-role="content">
			<ul data-role="listview" style="margin-top:-15px;">
				<li data-role="list-divider">点赞数统计</li>
					<li id="li01" th:text="${dzInfo}">
					</li>
				<li data-role="list-divider">评论管理</li>
			</ul>
			<br />
			<div style="margin-top: 10px;">
				
				<ul data-role = "listview" >
					<li id="li02" th:each="plmodel:${list}">

						<div class="ui-grid-a">
							<div class="ui-block-a">
								<p th:text="${plmodel.pltext}"></p>
							</div>
							<div class="ui-block-b">
								<a th:href="@{/delete(id=${plmodel.id})}" style="text-decoration: none;"><button >删除</button></a>
							</div>
						</div>

					</li>
				</ul>
			</div>
		</div>
		<div data-role="footer" data-position="fixed" data-theme="b">
			<div data-role="navbar" data="c">
				<ul>
					<li><a href="#" data-icon="info">后台信息</a></li>
				</ul>
			</div>
		</div>
    </div>
</body>
</html>